package com.tanhua.app.controller;

import com.tanhua.app.controllerservice.MessagesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
public class MessagesController {

    @Autowired
    private MessagesService messagesService;


    @PostMapping(name = "添加好友",value = "/messages/contacts")
    public ResponseEntity contacts(@RequestBody Map map){
        Integer userId = (Integer)map.get("userId"); //jack
        return messagesService.contacts(userId);
    }


    @GetMapping(name = "好友列表",value = "/messages/contacts")
    public ResponseEntity contacts(@RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "10")Integer pagesize, String keyword){
        System.out.println(page);
        System.out.println(pagesize);
        return messagesService.findFriendsList(page,pagesize);
    }



    @GetMapping(name = "查询点赞的用户列表",value = "/messages/likes")
    public ResponseEntity likes(@RequestParam(defaultValue = "1") Integer page,
                                   @RequestParam(defaultValue = "10")Integer pagesize){
        return messagesService.findPageUserInfo(page,pagesize,1);
    }

    @GetMapping(name = "查询评论的用户列表",value = "/messages/comments")
    public ResponseEntity comments(@RequestParam(defaultValue = "1") Integer page,
                                   @RequestParam(defaultValue = "10")Integer pagesize){
        return messagesService.findPageUserInfo(page,pagesize,2);
    }

    @GetMapping(name = "查询喜欢的用户列表",value = "/messages/loves")
    public ResponseEntity loves(@RequestParam(defaultValue = "1") Integer page,
                                   @RequestParam(defaultValue = "10")Integer pagesize){
        return messagesService.findPageUserInfo(page,pagesize,3);
    }












}
